public class Position
{

	private int x;
	private int y;

    /**
    * Constructor that only initializes the x and y values of the position.
    * It has special uses in the BFS process
    *
    * @param x Value for the x coordinate
    * @param y Value for the y coordinate
    */
    public Position(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    
    /**
     * Updates the x and y values using the parameter position.
     * @param p Position to use for X and Y values. 
     */
    public void updatePosition(Position p) 
    {
    	this.x = p.getX();
    	this.y = p.getY();
    }
    
    public void updatePosition(int x, int y) {
    	this.x = x;
    	this.y = y;
    }
    
	public int getX()
	{
		return x;
	}

	public void setX(int x)
	{
		this.x = x;
	}

	public int getY()
	{
		return y;
	}
	
	public Position copy()
	{
	    return new Position(this.getX(), this.getY());
	}

	public void setY(int y)
	{
		this.y = y;
	}
	
	/**
	 * Checks if the created Position is valid on a given Board or if it is out of borders (not maze given Borders, only index checking)
	 * @param Board to check
	 */
	public boolean isValidOnBoard(Board b)
	{
	   if (this.x >= 0 && this.y >= 0 && this.x < b.getElements().length && this.y < b.getElements()[this.x].length)
	      return true;
	   else return false;
	}
	
	/**
	 * Overrides method equals for Object class
	 * checks if x and y are equal.
	 */
	@Override
	public boolean equals(Object o)
	{
	   return ((((Position)o).getX() == this.x) && ((Position)o).getY() == this.getY()); 
	}
	
	/**
	 * Overrides method toString for Object class
	 */
	@Override
	public String toString() 
	{
		return "Row: " + x + ", Col: " + y;
				
	}
}
